/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author user
 */
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
public class JTable_add_ROW {

 static  DefaultTableModel model = new DefaultTableModel();

 static  JButton button = new JButton("OK");

 static Vector rowData=new Vector();

 public static class MyActionListener implements ActionListener
    {
        public void actionPerformed(ActionEvent evt)
        {
            JButton button = (JButton)evt.getSource();
            System.out.println("Добавить строку");
            rowData.add("");
            rowData.add("");
            model.insertRow(0, rowData);
        }
    }
public static void main(String[] args)
    {

 model.addColumn("Column1");

 model.addColumn("Column2");

 Vector rowData=new Vector();

 rowData.add("d1");

 rowData.add("d2");

 model.insertRow(0, rowData);

 JTable jtbl=new JTable(model);

 JPanel jp=new JPanel();

 jp.add(jtbl);

 Box box = new Box(BoxLayout.X_AXIS);

 int width = 10;

 box.add(Box.createHorizontalStrut(width));

 button.addActionListener(new MyActionListener());

        JFrame jf=new JFrame();
        box.add(jp);
        box.add(button);
        jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
        jf.getContentPane().add(box);
        jf.setSize(333, 333);
        jf.setVisible(true);
    }
}
